<?php

namespace Liuhelong\LaravelAdmin\Wechat\Http\Controllers;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use \Liuhelong\LaravelAdmin\Wechat\Models\WechatOffiaccountNew;

class WechatOffiaccountNewController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '图文消息';
    protected $description = [
        'index'  => '这里的图文消息用于自动回复',
        //        'show'   => 'Show',
        //        'edit'   => 'Edit',
        //        'create' => 'Create',
    ];

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new WechatOffiaccountNew());

        $grid->column('id', __('Id'))->hide();
        $grid->column('title',__('laravel_admin_wechat.Name'));
        $grid->column('description',__('laravel_admin_wechat.Description'));
        $grid->column('image', __('laravel_admin_wechat.Image'))->image();
        $grid->column('url',__('laravel_admin_wechat.Url') );
        $grid->column('created_at', __('laravel_admin_wechat.Created at'));
        $grid->column('updated_at', __('laravel_admin_wechat.Updated at'))->hide();

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(WechatOffiaccountNew::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('title', __('laravel_admin_wechat.Title'));
        $show->field('description', __('laravel_admin_wechat.Description'));
        $show->field('image', __('laravel_admin_wechat.Image'));
        $show->field('url', __('laravel_admin_wechat.Url'));
        $show->field('created_at', __('laravel_admin_wechat.Created at'));
        $show->field('updated_at', __('laravel_admin_wechat.Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new WechatOffiaccountNew());

        $form->text('title', __('laravel_admin_wechat.Title'));
        $form->textarea('description',__('laravel_admin_wechat.Description'));
        $form->image('image', __('laravel_admin_wechat.Image'))->fit('200','200');
        $form->url('url',__('laravel_admin_wechat.Url'));

        return $form;
    }
}
